import axios from 'axios'

axios.create({
  baseURL: '',
  timeout: 3000,
})

// export default instance

export const getCity = key => {
  return axios({
    url: `https://restapi.amap.com/v3/ip?key=${key}`,
    method: 'GET',
  })
}

export const getAdcode = (key,city) => {
  return axios({
    url: `https://restapi.amap.com/v3/ip?key=${key}&address=${city}`,
    method: 'GET',
  })
}

export const getWeather = (key,adcode) => {
  return axios({
    url: `https://restapi.amap.com/v3/weather/weatherInfo?city=${adcode}&key=${key}&extensions=base`,
    method: 'GET',
  })
}

export const getAllWeather = (key, adcode) => {
  return axios({
    url: `https://restapi.amap.com/v3/weather/weatherInfo?city=${adcode}&key=${key}&extensions=all`,
    method: 'GET',
  })
}

export const searchCity=(key,address)=>{
  return axios({
    url: `https://restapi.amap.com/v3/geocode/geo?key=${key}&address=${address}`,
    method: 'GET',
  })
}